/*************************************************
  * 描述：
  *
  * File：multiheader.h
  * Author：gaomaolong@mozihealthcare.cn
  * Date：2025-10-27
  * Update：
  * ************************************************/
#ifndef MULTIHEADER_H
#define MULTIHEADER_H

#pragma once
#include <QHeaderView>
#include <QMetaType>
#include <QPainter>

struct SpanRange
{
  int startRow = -1;
  int startCol = -1;
  int endRow = -1;
  int endCol = -1;

  bool isValid()
  {
    if (startRow < 0 || startCol < 0 || endRow < 0 || endCol < 0)
    {
      return false;
    }

    return true;
  }
};
Q_DECLARE_METATYPE(SpanRange);

class MutilHeader : public QHeaderView
{
  Q_OBJECT

public:
  MutilHeader(Qt::Orientation orientation, QWidget *parent = nullptr);
  ~MutilHeader();

  void setLabels(const QList<QStringList> &headers);

  void setRowHeight(int hight);

  void setSpanRange(const SpanRange &range);

protected slots:
    void onSectionResized(int logicalIndex, int oldSize, int newSize);

protected:
  virtual void paintSection(QPainter* painter, const QRect& rect, int logicalIndex) const;

  virtual QSize sectionSizeFromContents(int logicalIndex) const;

protected:
  int _rowHight = 50;
};



#endif //MULTIHEADER_H
